package util;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * @author weijie
 * @date 2020/5/26 13:38
 */
public class randomDemo {

    public static void main(String[] args) throws IOException {
//        //产生10000-99999之间的随机数
//        for (int i = 0; i< 100; i++){
//            System.out.println((int)(Math.random() * 100000));
//        }
//
//        String emailPattern = "^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,})";
//        Pattern compile = Pattern.compile(emailPattern);
//        String str = "97365228!1@qq.com";
//        Matcher matcher = compile.matcher(str);
//        System.out.println(matcher.matches());

        String path = "F:\\xhscms\\id.txt";
        List<String> list = FileUtils.readLines(new File(path));
        List<String> newsList = FileUtils.readLines(new File("F:\\storedNewsId.txt"));
        HashSet<String> ids = new HashSet<>(newsList);
        File file = new File("F:\\noStoredId.txt");
        ArrayList<String> noIds = new ArrayList<>();
        for (String id : list){
            id = id.trim();
            if (!ids.contains(id)){
                noIds.add(id + "\n");
                System.out.println(id);
            }
        }
        FileUtils.writeLines(file, noIds);
    }

}
